<?php

declare(strict_types=1);
/**
 * Author: Zane
 * Email: 873934580@qq.com
 * Date: 2023/5/27.
 */

namespace App\Models;

use Illuminate\Database\Eloquent\SoftDeletes;

class ModelBuild extends BaseModel
{
    use SoftDeletes;

    protected $table;

    /**
     * 这里要求数据表名称为完整表名.
     *
     * @param string $table // 数据表名称
     * @param string|null $connection // 设置模型链接
     * @return ModelBuild
     */
    public static function build(string $table, string $connection = null): self
    {
        $model = new static();
        $model->setTable(getTableName($table));
        if (null !== $connection) {
            $model->setConnection($connection);
        }
        $model->fillable = $model->getFillable();

        return $model;
    }
}
